package com.ruoyi.job.task;

import com.ruoyi.common.core.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @author 15332
 * @version 1.0
 * @date 2025/9/17 14:05
 * @description TODO
 */
@Component("ryDailyTask")
@Slf4j
public class RyDailyTask {
  @Autowired
  private RabbitTemplate rabbitTemplate;


  public void ryDaily() {
//    获取当天的日期
    String date = DateUtils.getDate();
    log.info("发布每日任务:{}",date);
    rabbitTemplate.convertAndSend("edu.daily.task.queue", date);
  }

  public void ryCheck() {
//    使用LocalDate获取当天的日期然后减一天
    LocalDate now = LocalDate.now();
    LocalDate format = now.minusDays(1);
    String date = format.format(DateTimeFormatter.ISO_LOCAL_DATE);
    log.info("检查每日任务:{}",date);
    rabbitTemplate.convertAndSend("edu.check.task.queue",date);
  }
}
